﻿<UserControl x:Class="theeg.DependencyAnalysis.CommonAddin.AddinWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:commonAddin="clr-namespace:theeg.DependencyAnalysis.CommonAddin"
             xmlns:models2="clr-namespace:theeg.DependencyAnalysis.CommonAddin.Models"
             xmlns:views="clr-namespace:theeg.DependencyAnalysis.CommonAddin.Views"
             mc:Ignorable="d" Background="Black"
             d:DesignHeight="600" d:DesignWidth="800" FontFamily="Segoe UI">
    <UserControl.CommandBindings>
        <CommandBinding Command="{x:Static commonAddin:AddinWindow.SortMetricsCommand}" Executed="SortMetricsExecuted"></CommandBinding>
        <CommandBinding Command="{x:Static commonAddin:AddinWindow.SelectCommand}" Executed="SelectExecuted"></CommandBinding>
    </UserControl.CommandBindings>
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/CommonStyles.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>

            <DataTemplate x:Key="ProjectItemTemplate" DataType="models2:Project">
                <CheckBox IsChecked="{Binding IsSelected}" Foreground="White" Margin="2" MinHeight="16">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="Resources/Module.png"></Image>
                        <TextBlock Text="{Binding Name}"></TextBlock>
                    </StackPanel>
                </CheckBox>
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="240"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="240"></RowDefinition>
        </Grid.RowDefinitions>
        <GridSplitter Grid.Column="1" HorizontalAlignment="Left" Width="8" Background="#FF196990"></GridSplitter>
        <GridSplitter Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="8" Background="#FF196990"></GridSplitter>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <Button Command="{Binding ReloadCommand}" Style="{StaticResource NullButtonStyle}">Reload</Button>
                    <Button Command="{Binding AnalyzeCommand}" Style="{StaticResource NullButtonStyle}">Analyze</Button>
                </StackPanel>
                <Border VerticalAlignment="Bottom" BorderBrush="#FF25334B" BorderThickness="2"></Border>
            </StackPanel>

            <ListBox ItemsSource="{Binding Projects}" Grid.Row="1" Background="Transparent" ItemTemplate="{StaticResource ProjectItemTemplate}" Foreground="White" BorderThickness="0"
                     BorderBrush="Transparent" IsEnabled="{Binding IsEnabled}" ScrollViewer.PanningMode="Both"></ListBox>
        </Grid>
        <Grid Grid.Column="1" Margin="8,0,0,0">
            <TabControl Background="Transparent" BorderThickness="0">
                <TabItem Header="Architecture">
                    <views:ArchitectureGraph Background="Transparent" DataContext="{Binding ArchitectureGraphModel}"
                                           ChangeDescriptorCommand="{Binding DataContext.ChangeDescriptorCommand, ElementName=proximity}" GraphContent="{Binding GraphContent}"
                                             HideNodesCommand="{Binding HideNodesCommand}"></views:ArchitectureGraph>
                </TabItem>
                <TabItem Header="Proximity">
                    <views:ProximityGraph x:Name="proximity" Background="Transparent" DataContext="{Binding ProximityModel}"
                                     ChangeDescriptorCommand="{Binding ChangeDescriptorCommand}" GraphContent="{Binding GraphContent}"></views:ProximityGraph>
                </TabItem>
                <TabItem Header="Adjacency Matrix">
                    <views:AdjacencyMatrix Background="Transparent" DataContext="{Binding AdjacencyMatrixModel}"></views:AdjacencyMatrix>
                </TabItem>
                <TabItem Header="Tests">
                    <views:CommonTests DataContext="{Binding CommonTestsModel}"></views:CommonTests>
                </TabItem>
                <TabItem Header="Cheat Sheet">
                    <views:CheatSheet></views:CheatSheet>
                </TabItem>
            </TabControl>
        </Grid>
        <Grid Background="Transparent" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,8,0,0">
            <views:MetricsGrid></views:MetricsGrid>
        </Grid>
        <views:DependencyList Margin="100" MaxWidth="1200" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.RowSpan="2"
                              Grid.ColumnSpan="2"
                                 Visibility="{Binding Dependencies, Converter={StaticResource IsNullToVisibilityConverter}}" ></views:DependencyList>
        <Grid Background="#AA333333" Grid.ColumnSpan="2" Grid.RowSpan="2" Visibility="{Binding IsAnalyzing, Converter={StaticResource BoolToVisibilityConverter}}">
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
                <TextBlock Text="Analyzing project..." FontWeight="Bold" Foreground="White" FontSize="24" HorizontalAlignment="Center"></TextBlock>
                <ProgressBar IsIndeterminate="True" Height="6" Margin="0,12" Width="300"></ProgressBar>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
